package me.zk.practice1.s;

/**
 * @author zhangkai
 * @date 2023/7/28 13:22
 */
public class LS11 {
    public int maxArea(int[] height) {
        int maxArea = 0;
        for (int i = 0; i < height.length-1; i++) {
            for (int j = 1; j < height.length; j++) {
                int x = j -i;
                int y = Math.min(height[i],height[j]);
                maxArea = Math.max(x*y, maxArea);
            }

        }
        return maxArea;

    }


    public int maxArea2(int[] height) {
        int maxArea = 0;
        int i = 0;
        int j = height.length-1;
        while (i < j) {
           maxArea = height[i] < height[j]?
                   Math.max(maxArea,(j-i)*height[i++]):
                   Math.max(maxArea,(j-i)*height[j--]);
        }

        return maxArea;
    }
}
